<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<div class="panel">
    <div id="notice-heading" class="panel-heading bg-gray-light">
        <h3 class="panel-title">公告通知<span id="title-duty-name-notice" class="text-muted"> | </span></h3>
    </div>

    <div class="panel-body">
        <form th:id="'form_notice_input'+${notice?.id}" class="form-horizontal bord-btm">

            <input type="hidden" name="keyId" th:value="${notice?.id}">
            <input type="hidden" name="flowDutyId">
            <input type="hidden" name="flowDutyName">

            <div class="form-group">
                <label class="col-md-3 control-label">标题<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-7">
                    <input disabled type="text" name="name" id="name" th:value="${notice?.name}" class="form-control" placeholder="请输入标题">
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">是否长期有效<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-7">
                    <input disabled id="ifForever" name="ifForever" type="checkbox" value="1" th:checked="${notice?.ifForever==1}">
                </div>
            </div>

            <div class="form-group" id="timeDiv" th:hidden="${notice?.ifForever==1}">
                <label class="col-md-3 control-label">生效日期<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-7">
                    <div class="input-group">
                        <input disabled type="text" class="form-control" name="startTime" id="startTime" th:value="${#dates.format(notice?.startTime, 'yyyy-MM-dd HH:mm:ss')}" placeholder="开始时间">
                        <span class="input-group-addon">to</span>
                        <input disabled type="text" class="form-control" name="endTime" id="endTime" th:value="${#dates.format(notice?.endTime, 'yyyy-MM-dd HH:mm:ss')}" placeholder="结束时间">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">通知内容<i class="fa fa-asterisk txt-color-red"></i></label>
                <div class="col-md-7">
                    <!--<textarea disabled id="content" name="content" th:text="${notice?.content}"></textarea>-->
                    <div class="well" th:utext="${notice?.content}">Lorem ipsum dolor sit amet.</div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-3 control-label">附件</label>
                <div class="col-md-7">
                    <input th:id="'fileIds'+${notice?.id}" name="fileIds" style="display: none" th:value="${notice?.fileIds}">
                </div>
            </div>


        </form>

    </div>

</div>

<script th:inline="javascript">

    var keyId = [[${notice?.id}]];
    var flowData = {
        keyId : keyId ? keyId : "",
        formId : "form_notice_input"+[[${notice?.id}]],
        path : "com.hanqian.kepler.core.entity.primary.education.Notice",
        titleId : "title-duty-name-notice"
    };
    var $form = $("#"+flowData.formId);

    $(function(){
        new Switchery($form.find("#ifForever")[0]);
        __init_dropzone_read("fileIds"+[[${notice?.id}]]);

        __flow_duty_handle(flowData);
        __flow_button_read_handle(flowData, fn_notice_approve, fn_notice_back, fn_notice_deny, fn_notice_edit);
    });

    function fn_notice_approve(){
        __confirm_dialog("", "确定通过审批吗？", function(dialogRef){
            __form_save(flowData.formId, "/notice/approve", function(data){
                if(data && data.state === 1){
                    dialogRef.close();
                    __layX_close(flowData.keyId);
                }
            })
        });
    }

    function fn_notice_back(){
        __confirm_dialog("", "确定退回吗？", function(dialogRef){
            __form_save(flowData.formId, "/notice/back", function(data){
                if(data && data.state === 1){
                    dialogRef.close();
                    __layX_close(flowData.keyId);
                }
            })
        });
    }

    function fn_notice_deny(){
        __confirm_dialog("", "确定否决吗？", function(dialogRef){
            __form_save(flowData.formId, "/notice/deny", function(data){
                if(data && data.state === 1){
                    dialogRef.close();
                    __layX_close(flowData.keyId);
                }
            })
        });
    }

    function fn_notice_edit(){
        __layX_close(flowData.keyId);
        __layX_html_read(flowData.keyId, "公告通知", "/notice/input?keyId="+flowData.keyId);
    }

</script>

</html>